/*
 * 
 * LegendShop 多用户商城系统
 * 
 *  版权所有,并保留所有权利。
 * 
 */
package com.legendshop.oa.dao.impl;

import com.legendshop.dao.impl.GenericDaoImpl;
import com.legendshop.dao.support.CriteriaQuery;
import com.legendshop.dao.support.EntityCriterion;
import com.legendshop.dao.support.PageSupport;
import com.legendshop.oa.constants.SysParameterEnum;
import com.legendshop.oa.dao.MailLogDao;
import com.legendshop.oa.model.MailLog;
import com.legendshop.oa.util.PropertiesUtil;

import java.util.List;
/**
 * The Class MailLogDaoImpl.
 */

public class MailLogDaoImpl extends GenericDaoImpl<MailLog, Long> implements MailLogDao {
     
    public List<MailLog> getMailLog(String userName){
    	return this.queryByProperties(new EntityCriterion().eq("userName", userName));
    }

	public MailLog getMailLog(Long id){
		return getById(id);
	}
	
    public void deleteMailLog(MailLog mailLog){
    	delete(mailLog);
    }
	
	public Long saveMailLog(MailLog mailLog){
		return (Long)save(mailLog);
	}
	
	public void updateMailLog(MailLog mailLog){
		 update(mailLog);
	}
	
	public PageSupport getMailLog(CriteriaQuery cq){
		return queryPage(cq);
	}

	@Override
	public PageSupport<MailLog> getMailLogPage(String curPageNO, MailLog mailLog) {
		CriteriaQuery cq = new CriteriaQuery(MailLog.class, curPageNO);
        cq.setPageSize(PropertiesUtil.getObject(SysParameterEnum.PAGE_SIZE, Integer.class));
        cq.eq("receiveName",mailLog.getReceiveName());
        cq.addDescOrder("sendTime");
		return queryPage(cq);
	}
	
 }
